import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { BillTemplateVO, BillTemplateForm, BillTemplateQuery } from '@/api/credit/bill/template/types';

/**
 * 查询账单拆分模板列表
 * @param query
 * @returns {*}
 */

export const listBillTemplate = (query?: BillTemplateQuery): AxiosPromise<BillTemplateVO[]> => {
  return request({
    url: '/credit/billTemplate/list',
    method: 'get',
    params: query
  });
};


export const listNoPageBillTemplate = (query?: BillTemplateQuery): AxiosPromise<BillTemplateVO[]> => {
  return request({
    url: '/credit/billTemplate/noPage/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询账单拆分模板详细
 * @param id
 */
export const getBillTemplate = (id: string | number): AxiosPromise<BillTemplateVO> => {
  return request({
    url: '/credit/billTemplate/' + id,
    method: 'get'
  });
};

/**
 * 新增账单拆分模板
 * @param data
 */
export const addBillTemplate = (data: BillTemplateForm) => {
  return request({
    url: '/credit/billTemplate',
    method: 'post',
    data: data
  });
};

/**
 * 修改账单拆分模板
 * @param data
 */
export const updateBillTemplate = (data: BillTemplateForm) => {
  return request({
    url: '/credit/billTemplate',
    method: 'put',
    data: data
  });
};

/**
 * 删除账单拆分模板
 * @param id
 */
export const delBillTemplate = (id: string | number | Array<string | number>) => {
  return request({
    url: '/credit/billTemplate/' + id,
    method: 'delete'
  });
};
